package cs2340.spring2012.droidception.toDo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class LoginActivity extends Activity implements OnClickListener {
	EditText loginName;
	EditText passwordName;
	Button login;
	Button register;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        loginName = (EditText)findViewById(R.id.editText1);
        passwordName = (EditText)findViewById(R.id.editText2);
        login = (Button)findViewById(R.id.button1);
        register = (Button)findViewById(R.id.button2);
        login.setOnClickListener(this);
        register.setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		
		if(v.getId() == (login.getId())) {
			String lgn = loginName.getText().toString();
			String passwrd = passwordName.getText().toString();
			if (lgn.equals("Susmita")&& (passwrd.equals("Susmita"))){
				setContentView(R.layout.success);
			}
			else{
				setContentView(R.layout.fail);
			}
		}
		else {
			if (v.getId() == (register.getId())){
				Intent i = new Intent();                 
				i.setClassName("cs2340.spring2012.droidception.toDo", "cs2340.spring2012.droidception.toDo.RegisterActivity");                 
				startActivity(i); 
			}
		}
	}
}